package test.com.sms.selenium.singlepoint.util;

import org.openqa.selenium.By;

import test.com.sms.selenium.framework.SeleniumPageUtil;
import test.com.sms.selenium.util.SeleniumUtil;

public class SpTicketDispatchPageUtil extends SeleniumPageUtil {
	public static final By DISPATCH_IMG_ASSGIN_FE = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table/tbody/tr[1]/td[1]/table/tbody/tr/td[1]/span[1]/img");
	public static final By DISPATCH_LABEL_ASSGIN_FE = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table/tbody/tr[1]/td[1]/table/tbody/tr/td[1]/span[1]/label");

	public static final By DISPATCH_IMG_UNASSGIN_FE = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table/tbody/tr[1]/td[1]/table/tbody/tr/td[1]/span[2]/img");
	public static final By DISPATCH_LABEL_UNASSGIN_FE = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table/tbody/tr[1]/td[1]/table/tbody/tr/td[1]/span[2]/label");
	
	public static final By DISPATCH_IMG_ON_SCHEDULE = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table/tbody/tr[1]/td[1]/table/tbody/tr/td[2]/span[1]/img");
	public static final By DISPATCH_LABEL_ON_SCHEDULE = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table/tbody/tr[1]/td[1]/table/tbody/tr/td[2]/span[1]/label");
	
	public static final By DISPATCH_IMG_UNASSIGNED = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table/tbody/tr[1]/td[1]/table/tbody/tr/td[2]/span[2]/img");
	public static final By DISPATCH_LABEL_UNASSIGNED = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table/tbody/tr[1]/td[1]/table/tbody/tr/td[2]/span[2]/label");
	
	public static final By DISPATCH_IMG_SLA_ALERT = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table/tbody/tr[1]/td[1]/table/tbody/tr/td[2]/span[3]/img");
	public static final By DISPATCH_LABEL_SLA_ALERT = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table/tbody/tr[1]/td[1]/table/tbody/tr/td[2]/span[3]/label");
	
	public static final By DISPATCH_INPUT_SLA_DATE = By.id("datepicker");
	public static final By DISPATCH_SELECT_STATUS = By.id("ctl44_ddlDate");
	public static final By DISPATCH_SELECT_WAREHOUSE = By.id("ctl44_ddlWarehouse");
	public static final By DISPATCH_BUTTON_FILTER_LIST = By.id("filterListButton");
	public static final By DISPATCH_BUTTON_ON_CALL_FE = By.id("btnREonCallRec1");
	public static final By DISPATCH_BUTTON_MAKE_RECOMMENDATION = By.id("btnFERecommendation2");
	
	public static final By DISPATCH_DIV_MAP = By.id("dvMap");
	public static final By DISPATCH_TABLE_INCIDENTS = By.name("ctl44_ListIncidents");
	
	/** elements of list*/
	public static final By DISPATCH_TH_TICKET = By.xpath("//*[@id='ctl44_ListIncidents_TicketsList_ReportOutput']/div/table/tbody/tr[1]/th[2]");
	public static final By DISPATCH_TH_PRI = By.xpath("//*[@id='ctl44_ListIncidents_TicketsList_ReportOutput']/div/table/tbody/tr[1]/th[3]");
	public static final By DISPATCH_TH_SLA_DEADLINE = By.xpath("//*[@id='ctl44_ListIncidents_TicketsList_ReportOutput']/div/table/tbody/tr[1]/th[4]");
	public static final By DISPATCH_TH_COMPANY = By.xpath("//*[@id='ctl44_ListIncidents_TicketsList_ReportOutput']/div/table/tbody/tr[1]/th[5]");
	public static final By DISPATCH_TH_CITY = By.xpath("//*[@id='ctl44_ListIncidents_TicketsList_ReportOutput']/div/table/tbody/tr[1]/th[6]");
	public static final By DISPATCH_TH_STATE = By.xpath("//*[@id='ctl44_ListIncidents_TicketsList_ReportOutput']/div/table/tbody/tr[1]/th[7]");
	public static final By DISPATCH_SPAN_STATUS = By.xpath("//*[@id='lblResults']/div[1]/div[2]/div[2]/div[2]/img");
	
	// tickets checkboxes
	public final static By DISPATCH_INPUT_TICKETS = By.xpath("//*[@id='ctl44_ListIncidents_TicketsList_ReportOutput']/div/table/tbody/tr/td[8]/input");
	
	/** elements of paging*/
	public static final By DISPATCH_INPUT_LAST = By.id("ctl44_ListIncidents_TicketsList_PagingBottom_imgLast");
	
	// the number before incident No.
	public static final By DISPATCH_DIV_NUMBER = By.xpath("//*[@id='ctl44_ListIncidents_TicketsList_ReportOutput']/div/table/tbody/tr/td[1]/div");
	
	public static void enterTicketDispathPage(){
		SpHomePageUtil.enter();
		SpHomePageUtil.enterTicketDispathPage();
		waitForDispathPageToLoad();
	}
	
	public static void waitForDispathPageToLoad() {
		SeleniumUtil.selectDefaultContent();
		SeleniumUtil.selectFrame(SpHomePageUtil.HOME_FRAME_CONTENT_NAME);
		SeleniumUtil.waitOnElements(new By[]{
				DISPATCH_IMG_ASSGIN_FE,DISPATCH_IMG_UNASSGIN_FE,DISPATCH_IMG_ON_SCHEDULE,DISPATCH_DIV_MAP,DISPATCH_TABLE_INCIDENTS
		});
	SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(DISPATCH_IMG_ASSGIN_FE));
	SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(DISPATCH_IMG_UNASSGIN_FE));
	SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(DISPATCH_IMG_ON_SCHEDULE));
	SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(DISPATCH_DIV_MAP));
	SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(DISPATCH_TABLE_INCIDENTS));
	}
}
